import { defineStore } from "pinia";

//定义ts数据类型
interface assth {
    id: number,
    title: string,
    status: boolean,
}
//定义容器
const useMainStore = defineStore('main', {
    state: () => {
        return {
            //存储数据
            todoList: [] as assth[],//使用定义的ts接口
        }
    },
    //显示总条数
    getters: {
        items(): number {
            return this.todoList.length
        }
    },
    actions: {
        //服务器的数据添加过来的，这边进行接收保存
        addtodoList(tododata: assth[]) {
            this.todoList = tododata
        },
        //添加到容器仓库
        addtodopush(tododata: assth) {
            this.todoList.push(tododata)
        },
        //删除容器仓库
        removedata(tododata: any) {
            this.todoList.splice(tododata, 1)
        },
        
    }
})
//导出，这是响应式数据
export { useMainStore, assth }